package com.example.demo.service.impl;

import com.example.demo.entity.Reply;
import com.example.demo.mapper.ReplyMapper;
import com.example.demo.service.ReplyService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ReplyServiceImpl implements ReplyService {

    @Resource
    ReplyMapper replyMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public List<Reply> getAllReply() {
        return replyMapper.getAllReply();
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public Reply getReplyByCommentId(Long commentId) {
        return replyMapper.getReplyByCommentId(commentId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public List<Reply> getReplyByAdminId(Long adminId) {
        return replyMapper.getReplyByAdminId(adminId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void deleteReplyByCommentId(Long commentId) {
        replyMapper.deleteReplyByCommentId(commentId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void deleteReplyByReplyId(Long replyId) {
        replyMapper.deleteReplyByReplyId(replyId);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void newReply(Reply reply) {
        replyMapper.newReply(reply);
    }
}
